package com.richpencil.utils.id;

import java.io.Serializable;

import com.richpencil.utils.DateUtils;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;
import org.springframework.data.mapping.MappingException;

public class IdDateTimeHelper extends IdentityGenerator {
    @Override
    public Serializable generate(SharedSessionContractImplementor session, Object object) throws MappingException {
        Object id =  DateUtils.GetCurrentDateTime();
        if (id != null) {
            return (Serializable) id;
        }
        return super.generate(session, object);
    }
}